/**
      <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <2011>  <André Mendes de Oliveira Paiva>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  
 */


package estrutura;

/**
 * Classe representa uma aresta, ou seja,  a ligação entre nós de uma estrutura de dados
 * 
 */
public class Aresta {

    private Object rotulo;
    private int peso;
    /**
     * Nome padrão para os rótulos sem nome
     */
    public String NOME_ROTULO_ANONIMO = "<Anonimo>";

    public Aresta(Object rotulo, int peso) {
        this.setRotulo(rotulo);
        this.setPeso(peso);
    }

    /**
     *
     * @param rotulo 
     */
    public Aresta(Object rotulo) {
        this(rotulo, 0);
    }
    /**
     *
     */
    public Aresta() {
        this(null, 0);
    }
    
    /**
     *
     * @param rotulo
     */
    public void setRotulo(Object rotulo) {
        this.rotulo = rotulo;
    }

    /**
     *
     * @return
     */
    public Object getRotulo() {
        return this.rotulo;
    }

    public void setPeso(int peso) {
        this.peso = peso;
    }
    public int getPeso() {
        return this.peso;
    }
    /**
     * 
     */
    public void imprimir()
    {
       System.out.print(this.toString());
    }
    @Override
    public String toString() {
        return (this.peso > 0 ? "Peso: " + this.peso: "")  + (this.rotulo == null ? NOME_ROTULO_ANONIMO : this.rotulo.toString());
    }
}
